# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=autosploit
pkgver=281.9a6a5ef
pkgrel=3
groups=('blackarch' 'blackarch-exploitation' 'blackarch-automation')
pkgdesc='Automate the exploitation of remote hosts.'
arch=('any')
url='https://github.com/NullArray/AutoSploit'
license=('GPL3')
depends=('python2' 'python2-requests' 'python2-psutil' 'python2-blessings'
         'python2-shodan' 'metasploit' 'sudo' 'python2-beautifulsoup4')
makedepends=('git')
source=("$pkgname::git+https://github.com/NullArray/AutoSploit.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo "$(git rev-list --count HEAD)"."$(git rev-parse --short HEAD)"
}

prepare() {
  cd $pkgname

  sed -i 's/sudo service {} start/sudo systemctl start {}/g' "$pkgname/main.py"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname/Docker"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md CONTRIBUTING.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/autosploit/LICENSE"

  rm *.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 ./$pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

